/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.university.entity;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.common.utils.Collections3;
import com.thinkgem.jeesite.modules.front.entity.Region;
import com.thinkgem.jeesite.modules.sys.entity.Dict;
import com.thinkgem.jeesite.modules.sys.entity.Role;

/**
 * 学校Entity
 * @author 朱俊吉
 * @version 2017-12-12
 */
public class University extends DataEntity<University> {
	
	private static final long serialVersionUID = 1L;
	private String name;		// 名称
	private Region province;		// 省份
	private Dict type;		// 院校类型
	private XueLiLevel xueLiLevel;		//学历等级
	private List<Dict> levelList = Lists.newArrayList(); //办学层次
	private Dict nature;		// 办学性质
	private Dict subjection;		// 隶属
	private Integer ranking;		// 全国排名
	private String url;		// 官方网站
	private String constitution;		// 招生章程
	private String intro;		// 简介
	private String address;		// 学校地址
	private String telephone;	//联系电话
	private String lable;		//标签
	private String logo;		// logo
	private String img;		// 图片
	private String code;		// 代码
	private Integer beginRanking;		// 开始 全国排名
	private Integer endRanking;		// 结束 全国排名
	
	//用于高校大全搜索
	private List<Region> provinceList = Lists.newArrayList();
	private List<Dict> typeList = Lists.newArrayList();
	private List<Dict> natureList = Lists.newArrayList();
	private List<Dict> subjectionList = Lists.newArrayList();
	
	public University() {
		super();
	}

	public University(String id){
		super(id);
	}

	@Length(min=1, max=255, message="名称长度必须介于 1 和 255 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@NotNull(message="省份不能为空")
	public Region getProvince() {
		return province;
	}

	public void setProvince(Region province) {
		this.province = province;
	}
	
	@NotNull(message="院校类型不能为空")
	public Dict getType() {
		return type;
	}

	public void setType(Dict type) {
		this.type = type;
	}
	
	@NotNull(message="学历层次不能为空")
	public XueLiLevel getXueLiLevel() {
		return xueLiLevel;
	}

	public void setXueLiLevel(XueLiLevel xueLiLevel) {
		this.xueLiLevel = xueLiLevel;
	}

	@JsonIgnore
	public List<Dict> getLevelList() {
		return levelList;
	}

	public void setLevelList(List<Dict> levelList) {
		this.levelList = levelList;
	}
	
	@JsonIgnore
	public List<String> getLevelValList() {
		List<String> levelValList = Lists.newArrayList();
		for (Dict level : levelList) {
			levelValList.add(level.getValue());
		}
		return levelValList;
	}

	public void setLevelValList(List<String> levelValList) {
		levelList = Lists.newArrayList();
		for (String levelVal : levelValList) {
			Dict level = new Dict();
			level.setValue(levelVal);
			levelList.add(level);
		}
	}

	@NotNull(message="办学性质不能为空")
	public Dict getNature() {
		return nature;
	}

	public void setNature(Dict nature) {
		this.nature = nature;
	}
	
	@NotNull(message="隶属不能为空")
	public Dict getSubjection() {
		return subjection;
	}

	public void setSubjection(Dict subjection) {
		this.subjection = subjection;
	}
	
	public Integer getRanking() {
		return ranking;
	}

	public void setRanking(Integer ranking) {
		this.ranking = ranking;
	}
	
	@Length(min=0, max=255, message="官方网站长度必须介于 0 和 255 之间")
	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	public String getConstitution() {
		return constitution;
	}

	public void setConstitution(String constitution) {
		this.constitution = constitution;
	}
	
	public String getIntro() {
		return intro;
	}

	public void setIntro(String intro) {
		this.intro = intro;
	}
	
	@Length(min=1, max=255, message="学校地址长度必须介于 1 和 255 之间")
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}
	
	@Length(min=1, max=13, message="联系电话长度必须介于 1 和 13 之间")
	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getLable() {
		return lable;
	}

	public void setLable(String lable) {
		this.lable = lable;
	}

	@Length(min=1, max=255, message="logo长度必须介于 1 和 255 之间")
	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}
	
	@Length(min=1, max=255, message="图片长度必须介于 1 和 1000 之间")
	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}
	
	@Length(min=0, max=64, message="代码长度必须介于 0 和 64 之间")
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
	
	public Integer getBeginRanking() {
		return beginRanking;
	}

	public void setBeginRanking(Integer beginRanking) {
		this.beginRanking = beginRanking;
	}
	
	public Integer getEndRanking() {
		return endRanking;
	}

	public void setEndRanking(Integer endRanking) {
		this.endRanking = endRanking;
	}

	/**
	 * 以下用于高校大全搜索
	 */
	@JsonIgnore
	public List<Region> getProvinceList() {
		return provinceList;
	}

	public void setProvinceList(List<Region> provinceList) {
		this.provinceList = provinceList;
	}
	/**
	 * 省份Id字符串, 多个用','分隔.
	 */
	public String getProvinceIds() {
		return Collections3.extractToString(provinceList, "id", ",");
	}
	
	@JsonIgnore
	public List<String> getProvinceIdList() {
		List<String> provinceIdList = Lists.newArrayList();
		for (Region region : provinceList) {
			provinceIdList.add(region.getId());
		}
		return provinceIdList;
	}

	public void setProvinceIdList(List<String> provinceIdList) {
		provinceList = Lists.newArrayList();
		for (String regionId : provinceIdList) {
			Region region = new Region();
			region.setId(regionId);
			provinceList.add(region);
		}
	}

	@JsonIgnore
	public List<Dict> getTypeList() {
		return typeList;
	}

	public void setTypeList(List<Dict> typeList) {
		this.typeList = typeList;
	}
	/**
	 * 院校类型value字符串, 多个用','分隔.
	 */
	public String getTypeVals() {
		return Collections3.extractToString(typeList, "value", ",");
	}
	
	@JsonIgnore
	public List<String> getTypeValList() {
		List<String> typeValList = Lists.newArrayList();
		for (Dict dict : typeList) {
			typeValList.add(dict.getValue());
		}
		return typeValList;
	}

	public void setTypeValList(List<String> typeValList) {
		typeList = Lists.newArrayList();
		for (String val : typeValList) {
			Dict dict = new Dict();
			dict.setValue(val);
			typeList.add(dict);
		}
		System.out.println(typeList.toString());
	}

	@JsonIgnore
	public List<Dict> getNatureList() {
		return natureList;
	}

	public void setNatureList(List<Dict> natureList) {
		this.natureList = natureList;
	}
	/**
	 * 办学性质value字符串, 多个用','分隔.
	 */
	public String getNatureVals() {
		return Collections3.extractToString(natureList, "value", ",");
	}
	
	@JsonIgnore
	public List<String> getNatureValList() {
		List<String> natureValList = Lists.newArrayList();
		for (Dict dict : natureList) {
			natureValList.add(dict.getValue());
		}
		return natureValList;
	}

	public void setNatureValList(List<String> natureValList) {
		natureList = Lists.newArrayList();
		for (String val : natureValList) {
			Dict dict = new Dict();
			dict.setValue(val);
			natureList.add(dict);
		}
	}

	@JsonIgnore
	public List<Dict> getSubjectionList() {
		return subjectionList;
	}

	public void setSubjectionList(List<Dict> subjectionList) {
		this.subjectionList = subjectionList;
	}
	/**
	 * 办学性质value字符串, 多个用','分隔.
	 */
	public String getSubjectionVals() {
		return Collections3.extractToString(subjectionList, "value", ",");
	}
	
	@JsonIgnore
	public List<String> getSubjectionValList() {
		List<String> subjectionValList = Lists.newArrayList();
		for (Dict dict : subjectionList) {
			subjectionValList.add(dict.getValue());
		}
		return subjectionValList;
	}

	public void setSubjectionValList(List<String> subjectionValList) {
		subjectionList = Lists.newArrayList();
		for (String val : subjectionValList) {
			Dict dict = new Dict();
			dict.setValue(val);
			subjectionList.add(dict);
		}
	}
	
	/**
	 * 办学层次label字符串, 多个办学层次名称用','分隔.
	 */
	public String getLevelNames() {
		return Collections3.extractToString(levelList, "label", ",");
	}
	/**
	 * 办学层次value字符串, 多个办学层次名称用','分隔.
	 */
	public String getLevelVals() {
		return Collections3.extractToString(levelList, "value", ",");
	}

}